#ifndef SRC_RPC_MODULE_SELECT_H
#define SRC_RPC_MODULE_SELECT_H

#include "include/event_manager.h"
#include <sys/select.h>

namespace rpc {
class Select : public EventManager {
  public:
    Select();
    virtual ~Select() {
    }

    bool Init();
    void Stop();

    bool Add(Event* ev, int falg);
    void Del(Event* ev, int flag);
    bool Mod(Event* ev, int flag);

    void Loop();
  private:
    int max_fd_;
    fd_set r_set_;
    fd_set w_set_;

    typedef std::map<int, Event*> EvMap;
    typedef EvMap::iterator EvIter;
    EvMap ev_map_;

    void AdjustMaxFd();

    DISALLOW_COPY_AND_ASSIGN(Select);
};
}

#endif
